<?php $__env->startSection('content'); ?>
    <div class="page-order-checkout">
        <div class="page-order-checkout-wrap">
            <div class="b1 icon_arrow" onclick="location.href='/address'">
                <?php if($address): ?>
                    <div class="b11"><p><span><?php echo e($address->name); ?></span><span><?php echo e($address->tel); ?></span></p></div>
                    <div class="b13">
                        <p id="address" data-id="<?php echo e(isset($address->id) ? $address->id : ''); ?>">
                            <?php echo e(isset($address->province) ? $address->province : ''); ?> <?php echo e(isset($address->city) ? $address->city : ''); ?> <?php echo e(isset($address->area) ? $address->area : ''); ?> <?php echo e(isset($address->detail) ? $address->detail : ''); ?>

                        </p>
                    </div>
                <?php else: ?>
                    <div class="b11"><p><span>没有收货地址!</span></p></div>
                    <div class="b13">
                        <p id="address" data-id="<?php echo e(isset($address->id) ? $address->id : ''); ?>">
                            <span style="color:#FF5722;">亲, 请先填写一个收货地址~</span>
                        </p>
                    </div>
                <?php endif; ?>
            </div>
            <div class="ui_line"></div>
            <div class="b2">
                <ul>
                    <?php /*<li class="on"><a href="javascript:;" class="alipaywap">支付宝支付</a></li>*/ ?>
                    <li class="on"><a href="javascript:;" class="wechatpay">微信支付</a></li>
                    <?php /*<li class=""><a href="javascript:;" class="">货到付款</a></li>*/ ?>
                </ul>
            </div>
            <div class="ui_line"></div>
            <!--
            <div class="b3 icon_arrow">
                <dl>
                    <dt><span>电子发票</span><strong>发票类型</strong></dt>
                </dl>
            </div>
            <div class="b3 icon_arrow">
                <dl>
                    <dt><span>不限送货时间</span><strong>送货时间</strong></dt>
                </dl>
            </div>
            <div class="ui_line"></div>
            -->

            <div class="b8">
                <?php foreach($carts as $cart): ?>
                    <div class="b8w">
                        <div class="b81">
                            <div class="img"><img src="<?php echo e($cart->product->thumb); ?>">
                            </div>
                        </div>
                        <div class="b82">
                            <div class="name"><p>
                                    <span><?php echo e($cart->product->name); ?></span></p></div>
                        </div>
                        <div class="b83">
                            <div class="price">
                                <?php if($cart->num > 1): ?>
                                    <span><?php echo e(doubleval($cart->product->price)); ?> x <?php echo e($cart->num); ?> = </span>
                                <?php endif; ?>
                                <strong><?php echo e(doubleval($cart->product->price)*$cart->num); ?>元</strong>
                            </div>
                        </div>
                    </div>
                <?php endforeach; ?>
            </div>
            <div class="ui_line"></div>

            <div class="b5">
                <div class="b51"><p><strong>商品价格：</strong><span><?php echo e($count['total_price']); ?>元</span></p></div>
                <div class="b53"><p><strong>配送费用：</strong><span>0元</span></p></div>
            </div>
            <div class="b7">
                <div class="b71"><span>共<?php echo e($count['num']); ?>件 合计: </span><strong><?php echo e($count['total_price']); ?>元</strong></div>
                <div class="b72"><a href="javascript:;" class="ui-button" id="pay"><span>去付款</span></a></div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>
    <script>
        $(function () {
            $("#pay").click(function () {
                var address_id = $("#address").data('id');
                if (address_id == '') {
                    alert('请先填写一个送货地址~');
                    return false;
                }

                $.ajax({
                    type: 'POST',
                    url: '/order',
                    data: {address_id: address_id},
                    success: function (data) {
                        //console.log(data);
                        if (data.status == '1') {
                            alert('订单提交成功!');
                            location.href='/order/pay/'+data.order_id;
                            return false;
                        }

                    }
                })
            })
        });
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('home.layouts.application', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>